package com.itchu.customer;

import com.itchu.system.domain.Score;
import com.itchu.system.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/api/score")
public class vScoreController {

    @Autowired
    private ScoreService scoreService;

    @RequestMapping("/addScore")
    public ResponseEntity<Void> addScore(Score score) {
        scoreService.addScore(score);
        return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    }

    @RequestMapping("/getScore")
    public ResponseEntity<Double> getAvgScore(@RequestParam("songlistId") Long songlistId) {

        Double avgScore = scoreService.getAvgScore(songlistId);

        return ResponseEntity.ok(avgScore);
    }

}
